<template>
  <div>
<h1>投资列表</h1>
理财名称:<input type="text" v-model="state.LName">
理财收益:<input type="text" v-model="state.Min">-<input type="text" v-model="state.Max">
<input type="button" value="查询" @click="show">
<table>
  <tr>
    <td>理财id</td>
    <td>理财名称</td>
    <td>理财收益</td>
    <td>理财最低金额</td>
    <td>理财人数</td>
    <td>操作</td>
  </tr>
  <tr v-for="item in list">
    <td>{{item.Lid}}</td>
    <td>{{item.LName}}</td>
    <td>{{item.ShouYi}}</td>
    <td>{{item.ZuiDi}}</td>
    <td>{{item.RenShu}}</td>
    <td>
      <input type="button" value="我要购买" @click="cai(item.Lid)">
    </td>
  </tr>
</table>
  </div>
</template>

<script setup lang="ts">
import {useRoute,useRouter} from 'vue-router'
import {reactive,toRefs,onMounted} from 'vue'
import axios from 'axios'
const route=useRoute()
const router=useRouter()

let data:any=reactive({
  state:{
    LName:'',
    Max:'',
    Min:''
  },
  list:[]
})

let {state,list}=toRefs(data)

onMounted(()=>{
  show()
})

const show=()=>{
axios({
  url:'/api/XinXi/GetShow',
  method:'get',
  params:state.value
})
.then(res=>{
  console.log(res.data);
  list.value=res.data.data;
  console.log(res.data.data.length);
})
.catch(err=>{
  console.log(err);
  
})
}

const cai=(Lid:any)=>{
router.push({
  path:'/licai',
  query:{
    Lid:Lid
  }
})
}
</script>

<style scoped>

</style>